"""
 -*- coding: utf-8-*-
 @File: page_edit_member.py
 @Author: chen
 @time: 2023/10/05/ 10:17
"""
import allure
from appium.webdriver.common.appiumby import AppiumBy

from hogwartsHomework.homework_app_auto_L3.dev.pages.page_base import BasePage
from hogwartsHomework.homework_app_auto_L3.utils.mgt_data_save import save_screenshot, save_page_source
from hogwartsHomework.homework_app_auto_L3.utils.mgt_log import logger


class EditMemberPage(BasePage):
    def click_delete_member(self):
        """点击删除成员按钮"""
        with allure.step("向下滑动屏幕"):
            logger.info("向下滑动屏幕")
            self.do_move(0.8, 0.2)
        button_delete_member = (AppiumBy.ID, 'com.tencent.wework:id/h0w')
        with allure.step("点击删除成员按钮"):
            logger.info("点击删除成员按钮")
            self.do_click(button_delete_member)
        return self

    def delete_ensure(self):
        """点击确认删除按钮"""
        button_delete_ensure = (AppiumBy.ID, 'com.tencent.wework:id/czz')
        with allure.step("点击确认删除按钮"):
            logger.info("点击确认删除按钮")
            self.do_click(button_delete_ensure)
            # save_screenshot(self.driver)
            # save_page_source(self.driver)
        from hogwartsHomework.homework_app_auto_L3.dev.pages.page_manage_member import MgtMemberPage
        logger.info("进入成员管理页面")
        return MgtMemberPage(self.driver)

    def delete(self):
        self.click_delete_member()
        self.delete_ensure()
        from hogwartsHomework.homework_app_auto_L3.dev.pages.page_manage_member import MgtMemberPage
        logger.info("进入成员管理页面")
        return MgtMemberPage(self.driver)
